﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1.DesignerPatter.Test
{
    class Person
    {
        private string name;

        public Person()
        { }
        public Person(string name)
        {
            this.name = name;
        }

        public virtual void Show()
        {
            Console.WriteLine("装扮的{0}",name);
        }
    }

    class Finery : Person
    {
        protected Person componet;

        public void Decorate(Person com)
        {
            this.componet = com;
        }

        public override void Show()
        {
            if (componet != null)
            {
                componet.Show();            
            }
        }
    }

    class TShirts:Finery
    {
        public override void Show()
        {
            Console.WriteLine("大T恤");
            base.Show();
        }
    }

    class BigTrouser : Finery
    {
        public override void Show()
        {
            Console.WriteLine("垮裤");
            base.Show();
        }
    }

    class TestDecorator
    {
        static void Main()
        {
            Person p = new Person("小菜");
            Console.WriteLine("第一种装扮：");

            BigTrouser b = new BigTrouser();
            TShirts t = new TShirts();

            b.Decorate(p);
            t.Decorate(b);
            t.Show();
            Console.Read();
        }
    }
}
